package com.dsg.kf.socket.context;

import java.util.Date;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.dsg.kf.common.util.NumberUtil;
import com.dsg.kf.socket.message.MessageBase;

/**
 * Concurrent 消息集合队列
 * @author pacy.pan
 *
 */
public class MessageConcurrentLinkedQueue {
	
	public static ConcurrentLinkedQueue<MessageBase> messagequeue = new ConcurrentLinkedQueue<MessageBase>();
	
	public static void offerMessageQueue(MessageBase base){
		if(base!=null){
			base.setId(String.valueOf(NumberUtil.getId()));
			base.setCreatedate(new Date());
			messagequeue.offer(base);
			System.out.println("-++++++++++++++++++++++++++++++============"+messagequeue.size());
		}
	}
	public static MessageBase pollMessageQueue(){
		while (!messagequeue.isEmpty()) {
	       return messagequeue.poll();
	    }
		return null;
	}
	
	public static void main(String args[]){
	}
	
}
